package com.mrjy.live.bo;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.entity.WisConsultInfo;
import com.mrjy.common.util.CharSetUtil;
import com.mrjy.live.dao.IWisConsultInfoDao;

@Service("wisConsultInfoBo")
public class WisConsultInfoBo implements IWisConsultInfoBo {
	@Resource
	private IWisConsultInfoDao WisConsultInfoDao;



	@Override
	public Map<String, Object> queryPageWisConsultInfo(WisConsultInfo wisConsultInfo,UserInfo userInfo) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total", WisConsultInfoDao.countWisConsultInfo(wisConsultInfo));
		List<WisConsultInfo> list = WisConsultInfoDao.queryPageWisConsultInfo(wisConsultInfo);	
		map.put("rows",list);
		return map;
	}

	@Override
	public int insert(WisConsultInfo wisConsultInfo) {
		wisConsultInfo.setConsultContent(CharSetUtil.toUTF8(wisConsultInfo.getConsultContent()));
		wisConsultInfo.setConsultTime(new Date().getTime());
		wisConsultInfo.setDisableFlag(0);
		return WisConsultInfoDao.insert(wisConsultInfo);
	}

	@Override
	public WisConsultInfo queryById(int id) {
		return WisConsultInfoDao.queryById(id);
	}

	@Override
	public int updateById(WisConsultInfo wisConsultInfo) {
		return WisConsultInfoDao.updateById(wisConsultInfo);
	}

	@Override
	public int deleteByIds(int[] ids) {
		try{
			return WisConsultInfoDao.deleteByIds(ids);
		}catch(DataAccessException  e){
			return 0;
		}
	}

	@Override
	public int updateDisableFlag(WisConsultInfo wisConsultInfo) {
		return WisConsultInfoDao.updateDisableFlag(wisConsultInfo);
	}

}
